package com.assignwork.modules.inportship;

import com.assignwork.dto.VoyageVisaSearchDTO;
import com.assignwork.dto.VoyageVisaSubmitDTO;
import com.assignwork.service.IVoyageVisaService;
import com.assignwork.vo.VoyageVisaPageVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

/**
 * @ClassName VoyageVisaController
 * @Description 船舶签证控制器
 * @Author dujianyu
 * @Date 2023/8/23 8:47
 */
@RestController
@AllArgsConstructor
@RequestMapping("voyageVisa")
public class VoyageVisaController extends BladeController {

    private IVoyageVisaService service;

    @GetMapping("/page")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "分页", notes = "传入dto")
    public R<IPage<VoyageVisaPageVO>> voyageVisaPage(VoyageVisaSearchDTO dto, Query query) {
        return R.data(service.selectVoyageVisaPage(dto, Condition.getPage(query)));
    }

    @PostMapping("submit")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "新增或修改", notes = "传入dto")
    public R<Boolean> submitVoyageVisa(@RequestBody VoyageVisaSubmitDTO dto) {
        return R.status(service.submitVoyageVisa(dto));
    }

    @PostMapping("/remove")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "删除", notes = "传入id")
    public R<Boolean> remove(@ApiParam(value = "主键集合", required = true) @RequestParam String id) {
        return R.status(service.deleteLogic(Func.toLongList(id)));
    }

    @GetMapping("/visaTonByVoyageId")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "分页", notes = "传入dto")
    public R<BigDecimal> visaTonByVoyageId(String voyageId) {
        return R.data(service.visaTonByVoyageId(voyageId));
    }

}
